package com.study.stream;

import org.junit.Test;

import java.util.OptionalLong;
import java.util.stream.LongStream;

/**
 * java8中的并行流
 * */
public class ForkJoinTest {

    @Test
    public void test(){
        Long start=System.currentTimeMillis();
        OptionalLong reduce = LongStream.rangeClosed(0, 10000000000L)
                .parallel()//并行流
                .reduce(Long::sum);
        Long end=System.currentTimeMillis();
        System.out.println("执行用时:"+(end-start));
    }
}
